import request from '@/utils/request'

// 创建订单
export function createOrder(data: any) {
  return request({
    url: '/user/orders',
    method: 'post',
    data
  })
}

// 获取订单列表
export function getOrders(params?: any) {
  return request({
    url: '/user/orders',
    method: 'get',
    params
  })
}

// 获取订单详情
export function getOrderDetail(orderNo: string) {
  return request({
    url: `/user/orders/${orderNo}`,
    method: 'get'
  })
}

// 取消订单
export function cancelOrder(orderNo: string) {
  return request({
    url: `/user/orders/${orderNo}/cancel`,
    method: 'post'
  })
}

// 支付订单
export function payOrder(orderNo: string) {
  return request({
    url: `/user/balance/pay/${orderNo}`,
    method: 'post'
  })
}

// 确认收货
export function confirmReceiveOrder(orderNo: string) {
  return request({
    url: `/user/orders/${orderNo}/receive`,
    method: 'post'
  })
}
